﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<link href="../tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../tablecloth/tablecloth.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php	

	include("../inc/joomlaInt_admin.php");
	include("../inc/inc_configuration.php");
	
	if ($jUser==0)
	{
		echo "Bitte zuerst einloggen!";
	}
	else
	{
	
		$q="SELECT gid FROM $tbl_users WHERE id=$jUser";
					$qe=mysql_query($q);
					$qeo=mysql_fetch_object($qe);
					
					$gid=$qeo->gid;
					
					if ($gid!=$admingroup)
					{
						echo "Du bist kein Admin!";
						break;
					}
	
		$liga=$_GET["liga"];
		
		$_SESSION["liga"]=$liga;
		
		$season=$_SESSION["season"];

		echo "	<table>
					<tr>
						<td>
							<table>";
		
		echo "	<tr>
					<td>
						<center>
							<form action='spielplan_erstellen.php' method='post'>
								<input type='hidden' name='liga' value='$liga'>
								<input type='submit' value='Spielplan erstellen' class='button anlegen'>
							</form>
							<br>
							<a href='spiele_entfernen.php?liga=$liga' class='button entfernen'>Alle Spiele löschen</a><br>
							<a href='spieltage_freigeben_v.php' class='button freigeben'>Spieltage freigeben</a><br>
							<a href='ligaspiele.php?liga=$liga' class='button freigeben'>Ligaspiele</a><br>
							<a href='rankings.php?liga=$liga' class='button rankings'>Rankings</a><br>
							<a href='unbestaetigte_spiele.php?liga=$liga' class='button'>Unbestätigte Spiele</a>
							<a href='liga_verwaltung.php?season=$season' class='button zurueck'>Zurück</a>
						</center>
					</td>";	
							
		echo"				<td>
								<table>
								<tr>
									<th>id</th>
									<th/>
									<th>Team</th>
									<th>Rating</th>
									<th>L</th>
								</tr>
						
				";
			
		$q = "	SELECT 
					lt.id AS id,
					t.id AS tId,
					t.name AS name,
					t.rating AS rating,
					l.seasonId AS sId
				FROM
					$tbl_leagues l,
					$tbl_lt lt,
					$tbl_teams t
				WHERE
					lt.teamId=t.id AND
					lt.leagueId=l.id AND
					l.id=$liga";
					
		$qe = mysql_query($q);
		
		while ($row=mysql_fetch_object($qe))
		{
			echo "	<tr>
						<td>",$row->id,"</td>
						<td><a href='../team_kader.php?team=",$row->tId,"'><img src='../$logopath",$row->tId,".png' width='$teamlogo_s_size' height='$teamlogo_s_size' alt=''></a></td>
						<td><a href='../team_kader.php?team=",$row->tId,"'>",$row->name,"</a></td>
						<td>",$row->rating,"</td>
						<td><a href='liga_team_entfernen.php?id=",$row->id,"' class='minibutton entfernen'></a></td>
					</tr>
						";
			$season = $row->sId;
		
		}
		
		echo "<tr><th colspan='5'></th></tr>";
		
		
		
		
		echo "</table><table><tr><td><form action='liga_team_hinzufuegen.php' method='post'>";
		
			$abfrage = "SELECT * FROM $tbl_teams ORDER BY name"; 
			$ergebnis = mysql_query($abfrage);
			
			echo '	<table>
						<tr>
							<td>Team hinzufügen:</td>
							<td><select name="team" Size="1">';
			
			while ($row = mysql_fetch_object($ergebnis))
				{
					echo '<Option Value="',$row->id,'">' ,$row->name, '</option>';
				}
				
			echo"	</select></td></tr>
					<tr><td><input hidden type='text' size='17' name='liga' value='",$liga,"'></td>
					<td><input type='submit' class='button anlegen' value='Hinzufügen'></td></tr></table>
					</form></td></tr>";
					
			
			echo "	</table></td>";		
			
			
			echo "</tr></table>";
	
	}



?>

</body>
</html>